﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infrastructure.ObjectModel;
using Microsoft.Xna.Framework;
using Infrastructure.Managers;
using Microsoft.Xna.Framework.Graphics;
using B10_Ex02_EladLebovitch_034695114.Interfaces;
using Infrastructure.ServiceInterfaces;

namespace B10_Ex02_Elad_034695114_Meyron_026607788.ObjectModel
{
    public class MotherShip : EnemySpriteBase
    {
        private const int k_Points = 400;
        private const string k_AsstetName = @"Sprites\MotherShip_32x120";
        private const int k_ShrinkSeconds = 1500;

        public MotherShip(Game i_game) : base(k_AsstetName, i_game)
        {
            this.Points = k_Points;
        }

        public override void Initialize()
        {
            // Init the parameters
            base.Initialize();
            this.ShrinkSeconds = k_ShrinkSeconds;
            this.TintColor = Color.Red;
            
            // Set location
            this.TopLeftPosition = new Vector2(Game.GraphicsDevice.Viewport.Width, this.Height);
            this.RotationOrigin = this.TextureCenter;
            this.Velocity = new Vector2(-(this.Width / 2), 0);
            this.Visible = true;
            this.Enabled = true;
        }

        public override void Update(GameTime gameTime)
        {
            // Check if ship is off screen
            if (this.PositionOfOrigin.X + this.Texture.Width < 0)
            {
                this.Distroy();
            }

            base.Update(gameTime);
        }

        /// <summary>
        /// What happens if spaceship gets hit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Collided(ICollidable i_Collidable)
        {
            if (i_Collidable is IHarmful && i_Collidable is IPlayerObjects)
            {
                // Tell everyone we died
                m_IsDying = true;
                (Game.Services.GetService(typeof(ISoundManeger)) as ISoundManeger).PlayCue("MotherShipKill");
            }
        }
    }
}